﻿using mediaControl.ViewModels;
using mediaControl.Vo;
using Prism.Events;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace mediaControl.Views
{
    /// <summary>
    /// Screen.xaml 的交互逻辑
    /// </summary>
    public partial class Screen4 : Window
    {
        public Screen4()
        {
            InitializeComponent();
        }

        public void SuppressScriptErrors(WebBrowser wb, bool hide)
        {
            FieldInfo fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
            if (fiComWebBrowser == null) return;

            object objComWebBrowser = fiComWebBrowser.GetValue(wb);
            if (objComWebBrowser == null) return;

            objComWebBrowser.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, objComWebBrowser, new object[] { hide });
        }

        private void web_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e)
        {
            SuppressScriptErrors(sender as WebBrowser, true);
        }
        private void Window_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (!IsEnabled)
            {
                this.Close();
            }

        }

        private void videoPlayer4_MediaOpened(object sender, RoutedEventArgs e)
        {
            imagePlayer4.Visibility = Visibility.Hidden;
            web4.Visibility = Visibility.Hidden;
            if (null != web4.Children && web4.Children.Count > 0)
            {
                web4.Children.RemoveAt(web4.Children.Count - 1);
            }
            imagePlayer4.Source = null;
            imagePlayer4Next.Source = null;
            imagePlayer4Next.Visibility = Visibility.Hidden;
            mainpImage4.Content = null;
            mainpImage4.Visibility = Visibility.Visible;
        }
    }
}
